<style>
.btn.btn-success-o{
    background: #fff;
    border: 1px solid red;
    color: #333;
}
.btn.btn-success-o.active{
    background: #fdb2b2;
    border: 1px solid red;
    color: red;
}
.btn.btn-success-o.active .subtitle{
    color: red;
}
.btn.btn-success-o.active::after{content:" ";width:23px;height:24px;background:url(../core/resource/images/gou-red.png) no-repeat;position:absolute;float:right;right:-1px;bottom:-1px;text-align:center;}
.jy-image-typetitle {
    float: right;
    top: 0.3rem;
    left: 0.2rem;
    padding: 2px 6px;
    position: absolute;
    color: #fff;
    background: #f60;
    font-size: 12px;
    border-bottom-right-radius: 16px;
	border-top-left-radius: 16px;
    z-index: 3;
}
</style>
<div ng-if="!pagedata.show_content || !pagedata.buyxieyi.content" class='fui-page fui-page-current'>
    <div class="fui-header">
		<div class="fui-header-left">
			<a class="back" ng-click="access_json('/merch.index/')"></a>
		</div>
		<div class="title">购买套餐</div> 
		<div class="fui-header-right">&nbsp;</div>
    </div>
    <div class="fui-content">
		<div ng-if="pagedata.vipbg" class="fui-picture">
				<a style="display: block; padding: {paddingtop}px {paddingleft}px;" data-nocache="true">
					<img ng-src="{{tomedia(pagedata.vipbg) || '../core/resource/images/nopic.jpg'}}">
				</a>
		</div>
		<div style="padding:0 0.5rem">
		<div ng-if="pagedata.errormsg" class="tips tips-yellow">
			<i class="fa fa-bullhorn"></i> [<red>温馨提示</red>]：{{pagedata.errormsg}}
		</div>
		<div style="padding:0.2rem;padding-top:1rem">
		<div class='bold' style="font-size:1rem">选择套餐</div>
		</div>
		<div class="fui-icon-group noborder col-2" style="margin-top:0.5rem">
			<div ng-repeat="item in pagedata.redfeeset" ng-click="pagedata.item.taocanid=item.id;pagedata.show_content=true;pagedata.istodown=false" class="fui-icon-col-sm" style="margin:0;padding:0 0.2rem;padding-top:1rem">
					<div ng-class="{'btn btn-success-o':1,'active':pagedata.item.taocanid==item.id}" style="line-height:1.4;margin:0;padding:1rem 0.3rem;width:100%">
					<div class="bold" style="font-size:1rem">￥{{item.money}}</div>
					<div class="subtitle" style="font-size:0.55rem">
					发职位{{item.jobnum}}/年,{{item.jobnum_day}}/天
					</div>
					<div class="subtitle" style="font-size:0.55rem">
					看简历{{item.notenum}}/年,{{item.notenum_day}}/天
					</div>
					</div>
					<div class="jy-image-typetitle">{{item.days}}天</div>
			</div>
		</div>
		<a href="javascript:;" class='btn btn-success block' style="background:red;border-radius:1rem;line-height: 3;margin-top:1.5rem" ng-click="pagedata.buyvip()">确认购买</a>
		<a href="javascript:;" class='btn btn-gray block' style="border-radius:1rem;line-height: 3;" ng-click="access_json('jy_51job/merch.index/')">返回中心</a>
		</div>
</div>
</div>
<div ng-if="pagedata.show_content && pagedata.buyxieyi.content" class='fui-page fui-page-current' id="xieyi" style="z-index:10;">
    <div class="fui-content">
		<div class="content-images" style="padding:0.5rem;">
			<div class="title bold" style="font-size:0.8rem">{{pagedata.buyxieyi.title || '合同协议'}} / <small>Read Ggree</small></div>
			<div class="text" style="padding-top:0.5rem;font-size:0.7rem;min-height:30rem" ng-bind-html="trust(pagedata.buyxieyi.content)">
			</div>
		</div>
		<div class="modal-footer fui-footer" style="height:auto">
			<div ng-click="access_json('jy_51job/merch.index/')" class="mod-fail">不同意</div>
			<div ng-if="pagedata.nowmiao==0 && pagedata.istodown" ng-click="pagedata.item.agree=1;pagedata.show_content=false" class="mod-success">我已阅读并同意</div>
			<div ng-if="pagedata.nowmiao!=0 || !pagedata.istodown" class="mod-success" style="background: #e6e6e6;">请先阅读完<span ng-if="pagedata.nowmiao!=0 && pagedata.istodown">({{pagedata.nowmiao}})</span></div>
		</div>
	</div>
</div>
<script>
scope.pagedata.buyvip=function(){
	scope.post_json('/merch.buyvip/post/',scope.pagedata.item,function(res){
		console.log('pay_id');console.log(res.payid);
		scope.tool.pay(res.payid,function(res){
				console.log('收到支付结果！');
				if(res.type=='success'){
					scope.message('购买成功！','','jy_51job/merch.index/');
				}else{
					scope.message('购买失败！'+res.message,'','jy_51job/merch.index/');
				}
		},'','','jy_51job/merch.index/');
	});
}
scope.pagedata.scroll_bottom=function(){
	console.log('到达底部了！');
	scope.$evalAsync();
	if(!scope.pagedata.istodown){
		scope.pagedata.miaodown();
	}
	scope.pagedata.istodown=true;
}
// 设置倒计时的总秒数
const totalSeconds = 3;
scope.pagedata.nowmiao=3;
scope.pagedata.miaodown=function(){
	// 初始化倒计时
	let secondsRemaining = totalSeconds;
	const intervalId = setInterval(() => {
	  secondsRemaining--;
	 // 将秒数转换成时分秒的格式
	  const minutes = Math.floor(secondsRemaining / 60);
	  const seconds = secondsRemaining % 60;
	  scope.pagedata.nowmiao=secondsRemaining;
	   // 如果倒计时结束，清除定时器
	  if (secondsRemaining <= 0){
		clearInterval(intervalId);
	  }
	  scope.$evalAsync();
	}, 1000);
}
</script>